<template>
	<view class="share">
		<view v-for="(item, index) in data" :key="index" class="listItem" @click="toInfo(item)">
			<image style="width: 20%;height: 50rpx;" v-if="item.Status==0" class="rightTag" src="../../static/subscript/daiqian.png" mode=""></image>
			<image style="width: 20%;height: 50rpx;" v-if="item.Status==1" class="rightTag" src="../../static/subscript/yiqian.png" mode=""></image>
			<image style="width: 20%;height: 50rpx;" v-if="item.Status==2" class="rightTag" src="../../static/subscript/juqian.png" mode=""></image>
			<image style="width: 20%;height: 50rpx;" v-if="item.Status==3" class="rightTag" src="../../static/subscript/chayi.png" mode=""></image>
			<image style="width: 20%;height: 50rpx;" v-if="item.Status==4" class="rightTag" src="../../static/subscript/zuofei.png" mode=""></image>
			<view class="flex">
				<span>销售方:</span>
				<b>{{ item.CompanyName }}</b>
			</view>
			<view class="flex" style="margin:15rpx 0">
				<span>货单号:</span>
				<b>{{ item.BillId }}</b>
			</view>
			<view class="flex">
				<span>日期:</span>
				<b>{{ item.CreateTime? item.CreateTime.substring(0, 19):"" }}</b>
			</view>
			<!-- <view class="tag" style="" @click="shareClick(item)">
				<button data-name="shareBtn" open-type="share" size="mini"
					style="background-color: #F74343;color:#fff">分享</button>
			</view> -->
		</view>
		<view class="more" v-if="data.length==0 || data.length==pagination.total" style="">
			没有更多了
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				pagination: {
					current: 1,
					pageSize: 10,
					total: 0,
				},
				data: [],
				params: "",
				query: null
			}
		},
		onLoad() {
			if (uni.getStorageSync('userInfo')) {
				this.Phone = uni.getStorageSync('userInfo').phone
			}
			// 获取提醒列表的参数
			this.GetWxCompayList()
		},
		//上拉加载更多
		onReachBottom() {
			if (this.pagination.current * this.pagination.pageSize >= this.pagination.total) return uni.showToast({
				title: '没有更多了',
				icon: 'none'
			})
			this.pagination.current += 1
			this.GetBillListData()

		},
		methods: {
			toInfo(item) {
				console.log(item);
				uni.navigateTo({
					url: '/pages/Share/shareInfo?id=' + item.Id
				})
			},
			// 分享
			shareClick(item) {
				console.log('分享', item)
				this.query = item
			},
			GetWxCompayList() {
				this.$http('POST', '/Base_Manage/Base_User/GetWxCompayList?Phone=' + this.Phone).then(res => {
					if (res.Success) {
						this.params = res.Data.join(',')
						this.GetBillListData()
					}
				})

			},
			// 获取提醒列表数据
			GetBillListData() {
				uni.showLoading({
					title: '加载中'
				})
				this.$http('POST', '/BO/BillList/GetBillList', {
					PageIndex: this.pagination.current,
					PageRows: this.pagination.pageSize,
					Search: {
						Status: "0",
						SupplieId: this.params
					},
					SortFieId: "Id",
					SortType: "desc"
				}).then(res => {

					if (res.Success) {
						this.pagination.total = res.Total
						this.data = this.data.concat(res.Data)
					}

					uni.hideLoading()

				})
			},
			onShareAppMessage(e) {
				console.log('分享了===', e, this.query.QrCode);
				return {
					title: '签收提醒',
					imageUrl: "https://www.yoojet.com/0108.png",
					path: '/pages/index/index?q=' + encodeURIComponent(this.query.QrCode)
				}
			}
		}
	}
</script>
<style>
	page {
		background-color: #d50700;
	}
</style>
<style scoped lang="scss">
	.share {
		height: 100%;
		background-color: #d50700;
		padding-top: 10rpx;
		padding-bottom: 50rpx;

		.more {
			text-align: center;
			padding: 20rpx;
			color: #fff
		}

		.listItem {
			background-color: #fff;
			border-radius: 10rpx;
			padding: 20rpx;
			margin: 20rpx;
			position: relative;
			overflow: hidden;

			.rightTag {
				position: absolute;
				right: 0;
				top: 0;
				width: 50px;
				height: 50px;
				margin: 10rpx 10rpx 0 0;
			}

			.flex {
				display: flex;
			}

			.tag {
				text-align: right;
				margin-bottom: 10rpx
			}

		}
	}
</style>